using Business.Models;
using Microsoft.EntityFrameworkCore;
using Volo.Abp;
using Volo.Abp.EntityFrameworkCore.Modeling;

namespace Business.EntityFrameworkCore
{
    public static class BusinessDbContextModelCreatingExtensions
    {
        public static void ConfigureBusiness(this ModelBuilder builder)
        {
            Check.NotNull(builder, nameof(builder));

            builder.Entity<Book>(b =>
            {
                b.ToTable("Book");

                b.ConfigureByConvention();

                b.Property(x => x.Name).IsRequired();


            });

            builder.Entity<PrintTemplate>(b =>
            {
                b.ToTable("base_print_template");

                b.ConfigureByConvention();

                b.Property(x => x.Name).IsRequired();
            });

            builder.Entity<WarehouseArea>(b =>
            {
                b.ToTable("WarehouseArea");

                b.ConfigureByConvention();
                
                b.Property(x => x.Name).IsRequired();
                b.Property(x => x.Code).IsRequired();
            });

            builder.Entity<Area>(b =>
            {
                b.ToTable("Area");

                b.ConfigureByConvention();
                
                b.Property(x => x.Code).IsRequired();
                b.Property(x => x.Name).IsRequired();
            });

            builder.Entity<WarehouseLocation>(b =>
            {
                b.ToTable("WarehouseLocation");

                b.ConfigureByConvention();
                
                b.Property(x => x.Code).IsRequired();
                b.Property(x => x.LocationHeight).IsRequired();
                b.Property(x => x.LocationLength).IsRequired();
                b.Property(x => x.LockPriority).IsRequired();
                b.Property(x => x.LocationWidth).IsRequired();
                b.Property(x => x.LoadBearing).IsRequired();
                b.Property(x => x.LocationVolume).IsRequired();
            });

            builder.Entity<WaitingOutbound>(b =>
            {
                b.ToTable("WaitingOutbound");

                b.ConfigureByConvention();
                
                b.Property(x => x.Reminder).IsRequired();
                b.Property(x => x.Phone).IsRequired();
                b.Property(x => x.DeliveryMethod).IsRequired();
                b.Property(x => x.OrderNote).IsRequired();
                b.Property(x => x.TrackingNumber).IsRequired();
                b.Property(x => x.DetailedAddress).IsRequired();
                b.Property(x => x.ExternalStatus).IsRequired();
                b.Property(x => x.Buyer).IsRequired();
                b.Property(x => x.LocationStock).IsRequired();
                b.Property(x => x.Pay).IsRequired();
                b.Property(x => x.BuyerMessage).IsRequired();
                b.Property(x => x.Discount).IsRequired();
                b.Property(x => x.Carrier).IsRequired();
                b.Property(x => x.Consignee).IsRequired();
                b.Property(x => x.OrderNumber).IsRequired();
                b.Property(x => x.ExternalOrderNumber).IsRequired();
                b.Property(x => x.OnlineOrderNumber).IsRequired();
                b.Property(x => x.Weight).IsRequired();
                b.Property(x => x.PickingArea).IsRequired();
                b.Property(x => x.Freight).IsRequired();
                b.Property(x => x.OrderTime).IsRequired();
                b.Property(x => x.OutboundType).IsRequired();
                b.Property(x => x.WarehouseOrderTime).IsRequired();
                b.Property(x => x.TotalGoods).IsRequired();
                b.Property(x => x.PaymentTime).IsRequired();
                b.Property(x => x.PlatformStore).IsRequired();
                b.Property(x => x.WeightEstimation).IsRequired();
                b.Property(x => x.ArrivalTime ).IsRequired();
                b.Property(x => x.Mark).IsRequired();
                b.Property(x => x.Brand).IsRequired();
                b.Property(x => x.LatestShipmentTime).IsRequired();
                b.Property(x => x.AttributionWave ).IsRequired();
                b.Property(x => x.Volume).IsRequired();
                b.Property(x => x.WaitingTimeoutTime).IsRequired();
                b.Property(x => x.RemainingShipmentTime ).IsRequired();
            });

            builder.Entity<Inventory>(b =>
            {
                b.ToTable("Inventory");

                b.ConfigureByConvention();
                
                b.Property(x => x.InventoryNameImage).IsRequired();
                b.Property(x => x.InventoryName).IsRequired();
                b.Property(x => x.InventoryNo).IsRequired();
                b.Property(x => x.Inventorynumber).IsRequired();
                b.Property(x => x.Investoryvolume).IsRequired();
                b.Property(x => x.InventoryCompany).IsRequired();
            });

            builder.Entity<Inventoryquantity>(b =>
            {
                b.ToTable("Inventoryquantity");

                b.ConfigureByConvention();
                
            });

            builder.Entity<Inventorytransit>(b =>
            {
                b.ToTable("Inventorytransit");

                b.ConfigureByConvention();
                
            });

            builder.Entity<Inventorywarning>(b =>
            {
                b.ToTable("Inventorywarning");

                b.ConfigureByConvention();
                
            });

            builder.Entity<Inventorystrategy>(b =>
            {
                b.ToTable("Inventorystrategy");

                b.ConfigureByConvention();
                
                b.Property(x => x.StrategyName).IsRequired();
                b.Property(x => x.StrategyNo).IsRequired();
                b.Property(x => x.Strategyappointment).IsRequired();
            });

            builder.Entity<Inventoryadjustment>(b =>
            {
                b.ToTable("Inventoryadjustment");

                b.ConfigureByConvention();
                
                b.Property(x => x.AdjustmentOperator).IsRequired();
                b.Property(x => x.AdjustmentdocumentNo).IsRequired();
                b.Property(x => x.Adjustmentremarks).IsRequired();
            });

            builder.Entity<Inventory>(b =>
            {
                b.ToTable("Inventory");

                b.ConfigureByConvention();
                
                b.Property(x => x.InventoryNameImage).IsRequired();
                b.Property(x => x.InventoryName).IsRequired();
                b.Property(x => x.InventoryNo).IsRequired();
                b.Property(x => x.Inventorynumber).IsRequired();
                b.Property(x => x.Investoryvolume).IsRequired();
                b.Property(x => x.InventoryCompany).IsRequired();
            });

            builder.Entity<Inventoryquantity>(b =>
            {
                b.ToTable("Inventoryquantity");

                b.ConfigureByConvention();
                
            });

            builder.Entity<Inventorytransit>(b =>
            {
                b.ToTable("Inventorytransit");

                b.ConfigureByConvention();
                
            });

            builder.Entity<Inventorywarning>(b =>
            {
                b.ToTable("Inventorywarning");

                b.ConfigureByConvention();
                
            });

            builder.Entity<Inventorystrategy>(b =>
            {
                b.ToTable("Inventorystrategy");

                b.ConfigureByConvention();
                
                b.Property(x => x.StrategyName).IsRequired();
                b.Property(x => x.StrategyNo).IsRequired();
                b.Property(x => x.Strategyappointment).IsRequired();
            });

            builder.Entity<Inventoryadjustment>(b =>
            {
                b.ToTable("Inventoryadjustment");

                b.ConfigureByConvention();
                
                b.Property(x => x.AdjustmentOperator).IsRequired();
                b.Property(x => x.AdjustmentdocumentNo).IsRequired();
                b.Property(x => x.Adjustmentremarks).IsRequired();
            });

            builder.Entity<Inventory>(b =>
            {
                b.ToTable("Inventory");

                b.ConfigureByConvention();
                
                b.Property(x => x.InventoryNameImage).IsRequired();
                b.Property(x => x.InventoryName).IsRequired();
                b.Property(x => x.InventoryNo).IsRequired();
                b.Property(x => x.Inventorynumber).IsRequired();
                b.Property(x => x.Investoryvolume).IsRequired();
                b.Property(x => x.InventoryCompany).IsRequired();
            });

            builder.Entity<Inventoryquantity>(b =>
            {
                b.ToTable("Inventoryquantity");

                b.ConfigureByConvention();
                
            });

            builder.Entity<Inventorytransit>(b =>
            {
                b.ToTable("Inventorytransit");

                b.ConfigureByConvention();
                
            });

            builder.Entity<Inventorywarning>(b =>
            {
                b.ToTable("Inventorywarning");

                b.ConfigureByConvention();
                
            });

            builder.Entity<Inventorystrategy>(b =>
            {
                b.ToTable("Inventorystrategy");

                b.ConfigureByConvention();
                
                b.Property(x => x.StrategyName).IsRequired();
                b.Property(x => x.StrategyNo).IsRequired();
                b.Property(x => x.Strategyappointment).IsRequired();
            });

            builder.Entity<Inventoryadjustment>(b =>
            {
                b.ToTable("Inventoryadjustment");

                b.ConfigureByConvention();
                
                b.Property(x => x.AdjustmentOperator).IsRequired();
                b.Property(x => x.AdjustmentdocumentNo).IsRequired();
                b.Property(x => x.Adjustmentremarks).IsRequired();
            });

            builder.Entity<OrderLiveWareOUT>(b =>
            {
                b.ToTable("OrderLiveWareOUT");

                b.ConfigureByConvention();
                
            });

            builder.Entity<Purchase>(b =>
            {
                b.ToTable("Purchase");

                b.ConfigureByConvention();
                
                b.Property(x => x.Name).IsRequired();
                b.Property(x => x.Remark ).IsRequired();
                b.HasIndex(x => x.Name);

            });

            builder.Entity<Plan>(b =>
            {
                b.ToTable("Plan");

                b.ConfigureByConvention();
                
                b.Property(x => x.Odd).IsRequired();
                b.Property(x => x.Planner).IsRequired();
                b.Property(x => x.Remark).IsRequired();
                b.HasIndex(x => x.Odd);

            });

            //Code generation...

            builder.Entity<Warehouse>(b =>
            {
                b.ToTable("Warehouse");

                b.ConfigureByConvention();

                b.Property(x => x.WarehouseName).IsRequired();


            });
        }
    }
}
